﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace FanaticRock.Core.ServiceInterfaces
{
    ///<summary>本地数据库相关服务。</summary>
    public interface ILocalDbService
    {
        void Flush();

        void Init();

        bool IsChanged();

        void SetChanged();

        Task<T> UpsertAsync<T>(T obj);

        Task UpsertAsync<T>(IEnumerable<T> obj);

        Task<T> GetByIdAsync<T>(string id);

        Task<IEnumerable<T>> Where<T>(Expression<Func<T, bool>> predicate);

        Task<T> FirstOrDefault<T>(Expression<Func<T, bool>> predicate);

        Task<IEnumerable<T>> Query<T>();

        Task Query<T>(Action<IEnumerable<T>> action);

        Task Clear<T>();
    }
}
